/*
	实现了链表表示的栈，不过是逆序的，而且这个版本包含头节点
*/
#include <stdlib.h>
#include <stdio.h>
typedef struct stackNode* link;
typedef struct stackNode{
	int data;
	struct stackNode* next;
}stackNode; 
stackNode *stackInitial(){
	link h = (link)malloc(sizeof(stackNode));
	h->next = NULL;
	return h;
}
void stackInsert(link head, int in){
	link temp = (link)malloc(sizeof(stackNode));
	temp->data = in;
	temp->next = head->next;
	head->next = temp;
}
/*int stackGet(link head){
	link temp = head->next;	
	int re = temp->data;
	head->next = temp->next;
	free(temp);
	return re;
}*/
void stackGet(link head){
	link temp = head->next;	
	int re = temp->data;
	head->next = temp->next;
	free(temp);
	printf("%d\n",re);
}

void stackEmpty(link head){
	printf("%d", head->next == NULL);
} 
/*int stackEmpty(link head){
	return head->next == NULL;
}*/ 
int main(){
	link head;
	head = stackInitial();
	stackInsert(head, 10);
//	printf("%d", stackGet(head));
	stackEmpty(head);
	stackGet(head);
	stackEmpty(head);
}
